import path from 'path';
import webpack from 'webpack';
// in case you run into any typescript error when configuring `devServer`
import 'webpack-dev-server';

const config: webpack.Configuration = {
  mode: 'production',
  entry: {
    "src/index": './src/index.ts',
    "src/sino-letter-list": './src/sino-letter-list.ts',
    "src/sino-word-list": './src/sino-word-list.ts',
  },
  output: {
    globalObject: `typeof self !== 'undefined' ? self : this`,
    libraryTarget: 'umd', 
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js',
  },
  resolve: {
    extensions: [".ts"]
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: [
          "ts-loader",
          "babel-loader"
        ],
        include: [
          path.join(__dirname, "src")
        ]
      },
      {
        test: /\.js$/,
        loader: "babel-loader"
      }
    ]
  }
};

export default config;